﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace FDEE.Model
{

    public class TendonCollection : List<TendonBase>
    {
        public new void Add(TendonBase item, ref System.Data.DataTable dt)
        {
            item.SetLength();
            item.SetElongation(ref dt,0.1);
            foreach (TendonBase kk in this.ToList())
            {
                if (kk.MTendonMark == item.MTendonMark)
                {
                    throw new Exception("预应力编号已存在。");
                }
            }

            base.Add(item);
        }
    }

    public class RebarCollection : List<RebarBase>
    {
        /// <summary>
        /// 增加一条钢筋记录，并提前算好钢筋长度
        /// </summary>
        /// <param name="item"></param>
        public new void Add(RebarBase item)
        {
            item.SetLength();
            if (item.Length>12000)
            {
                throw new Exception(string.Format("{0}号钢筋长度错误！",item.ToString()));
            }

            foreach (RebarBase kk in this.ToList())
            {
                if (kk.MBarMark==item.MBarMark && kk.SBarMark==item.SBarMark && kk.CBarMark==item.CBarMark)
                {
                    MessageBox.Show("钢筋编号"+ kk.MBarMark +"."+ kk.SBarMark + kk.CBarMark + "已存在,请核对数据！", "提示"); 
                }
            }

            base.Add(item);
        }
    }
}
